<?php

namespace App\Http\Controllers\Seller;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class BaseController extends Controller
{

    protected $shop;
    protected $sysMessageView = 'seller.message';
    /**
     * BaseController constructor.
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->assign(['menu'=>'']);

        $this->middleware(function (Request $req, $next){
            $this->shop = $this->user()->shop;
            if (!$this->shop)
            {
                return redirect('seller/shop');
            }

            if (!$this->shop->auth_status)
            {
                return redirect('seller/shop/unauthenticate');
            }

            return $next($req);
        });
    }
}
